<?php
require_once("includes/preload.php");

function posts($style) {
	global $glob_posts;

	// Get the ID of the last post; helps with ordering them properly
	$lastid = $glob_posts['latpostid'];
	
	// The $id variable is used for the 'while' loop
	$id = $lastid;
	
	// Read template data
	$template_data = file_get_contents("design/styles/".$style."/templates/posts.tpl.php");
	
	
	// Format the template for use in the first post
	$template = template("posts",true,true,$id);
	// Then stick the formatted post into the page
	$return .= $template;
	// And update the ID of the post we're working with
	$id--;
	
	// The WHILE loop does the same as before, but over and over again until there are no more posts to be worried about.
	while ($id >= 1)
	{
		$template = template("posts",true,true,$id);
		$return .= $template;
		$id --;
	}
	return $return;
}
?>